<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<style>
    div {
        margin: 300px auto;
        width: 500px;
        height: 200px;
        background-color: yellow;
        font-size: 25px;
        font-weight: 700;
        line-height: 200px;
        text-align: center;
        opacity: 0.6;
    }
</style>

<body>

</body>
<script>
    function countDown() {
        var nowTime = new Date(); // 返回的是当前时间总的毫秒数

        var y = nowTime.getFullYear()//年

        var month = nowTime.getMonth() + 1//月
        month = month < 10 ? '0' + month : month;
        var d = nowTime.getDate() // 日
        d = d < 10 ? '0' + d : d;
        var day = nowTime.getDay()
        var arr = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
        var xingqi = arr[day - 1]
        var h = nowTime.getHours() //时
        h = h < 10 ? '0' + h : h;
        var m = nowTime.getMinutes() // 分
        m = m < 10 ? '0' + m : m;
        var s = nowTime.getSeconds() // 当前的秒
        s = s < 10 ? '0' + s : s;
        return `${y}年${month}月${d}日${xingqi}${h}:${m}:${s}`
    }
    console.log(countDown());

    var div = document.createElement('div')
    document.querySelector('body').appendChild(div)
    div.innerHTML = countDown()
    setInterval(function () {
        div.innerHTML = countDown()
    }, 1000)
</script>

</html>